<template>
	<view style="line-height: 0;">
		<wxc-flex style="width:100%;" dir='top'>
		  <!-- <view style=''></view> -->
		  <view class="back">
		  	<text @click="back()" class="iconfont icon-left"></text>
		  </view>
		  <block v-for='(item,index) in data_list' :key='index'>
		      <image @click="onGoNext(item)" style='width:100%;' :src='item.src' mode='widthFix' ></image>
		  </block>
		</wxc-flex>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: [],
				params:[],
				data_list:[]
			};
		},
		onLoad: function(options) {
			console.log(options)
		    let content = JSON.parse(decodeURIComponent(options.content));
			
		    let params = options.params ? JSON.parse(options.params) : "";
			console.log("params<<<<<<<<<<<<<<<<<<<<<<<<<<<",params)
		    let list = params ? params.body : [];
		    console.log("list---------------->",list);
		    let temp = [];
			content.forEach(item => {
			      temp.push({src:item})
			});
		    if(params !== "") {
		      list.forEach(item => {
		        temp[parseInt(item.index) - 1].type = item.type;
		        temp[parseInt(item.index) - 1].id = item.id;
		      })
		    }
		    console.log("组装完成后的temp------------>",temp);
		    this.data_list = temp
		},
		onGoNext:function (e) {
		    var item = e
		    if(!item.type){
		      console.log("图片未维护type");
		      return;
		    }
		      switch (item.type) {
		      //景区
		        case "1":
		          uni.navigateTo({
		            url: '../scence/scencedetail?id=' + item.id,
		            success: function(res) {},
		            fail: function(res) {},
		            complete: function(res) {},
		          });
		          break;
		          //酒店
		        case "2":
		          uni.navigateTo({
		            url: '../hotel/hoteldetail?id=' + item.id + "&inDate="+'&outDate=',
		          })
		          break;
		
		      }
		  },
		  methods:{
			  back() {
			  	uni.navigateBack({
			  		delta: 1
			  	});
			  },
		  }
	}
</script>

<style lang="scss">
	.back{
		position: fixed;
		top:60upx;
		left: 30upx;
		border-radius: 50%;
		width: 60upx;
		height: 60upx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: rgba(255,255,255,0.6);
		text{
			font-size: 45upx;
		}
		
		z-index: 20;
	}
</style>
